package org.apache.jsp.admin;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanEnlaces;
import mapping.Enlace;

public final class enlaces_005fadmin_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=utf-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      out.write('\n');
      beans.BeanEnlaces mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanEnlaces) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanEnlaces();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\n');

	if(session.getAttribute("usuario") == null){
		throw new IllegalArgumentException("Oye! No intentes acceder a esta pagina sin haberte logueado antes.<br/>"+ 
		"Si ya te logueaste es posible que tu sesion haya expirado; en ese caso, vuelve a introducir tu usuario y contrase&ntilde;a");
	}
	if(!session.getAttribute("es_admin").equals(new Integer(1))) {
		throw new IllegalArgumentException("Para acceder a esta pagina debes ser administrador.<br/> Volver al <a href='../index.jsp'>inicio</a>");
	}

      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
      out.write("<!--  VALIDADO :-D -->\n");
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
      out.write("<head>\n");
      out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n");
      out.write("\t<link rel=\"stylesheet\" href=\"../estilos/style.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\"/>\n");
      out.write("\t<script src=\"../ajax/scriptaculous-js-1.8.1/lib/prototype.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"../ajax/scriptaculous-js-1.8.1/src/effects.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"../ajax/ajax_utils.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"../ajax/ajax_login.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"../js/menu.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<script src=\"../ajax/ajax_enlaces.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n");
      out.write("\t<title>ErasmusHelp - Administraci&oacute;n de enlaces</title>\n");
      out.write("</head>\n");
      out.write("<body onload=\"ocultaSubMenu()\">\n");
      out.write("\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "hidden_admin.jsp", out, false);
      out.write("\n");
      out.write("\t<div id='page_wrapper'>\n");
      out.write("\t\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "cabecera_admin.jsp", out, false);
      out.write('\n');
      out.write('	');
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "menu_admin.jsp", out, false);
      out.write("\n");
      out.write("\t\n");
      out.write("\t<div id='content_wrapper'>\n");
      out.write("\t\n");
      out.write("\t<div class='spacer'></div> \n");
      out.write("\t\n");
      out.write("\t<div id='contenido'>\n");
      out.write("\t\n");
      out.write("\t\t<div id=\"div_form_enlaces\">\n");
      out.write("\t\t<form id=\"form_enlaces\" action=\"enlaces.jsp\" method=\"get\" onsubmit=\"return false\">\n");
      out.write("\t\t\t<!-- OJO!\n");
      out.write("\t\t\t The form-element cannot have inline elements,like input, as direct child. \n");
      out.write("\t\t\tNormally on would use the fieldset-element to group the form control-elements.\n");
      out.write("\t\t\t -->\n");
      out.write("\t\t\t<input type=\"hidden\" id =\"iniciotupla\"  name=\"iniciotupla\" size=\"2\" readonly=\"readonly\" value=\"0\"/>\n");
      out.write("\t\t\t<div id=\"wrapper_formenlaces\">\n");
      out.write("\t\t\t<fieldset>\n");
      out.write("\t\t\t<legend>Buscar enlaces&nbsp;</legend>\n");
      out.write("\t\t\t\t<div id=\"cajaformenlaces\">\n");
      out.write("\t\t\t\t\t<div class=\"formenlace\">\n");
      out.write("\t\t\t\t\t\t<label for=\"nom_enlace\">Nombre</label>\n");
      out.write("\t\t\t\t\t\t<input id=\"nom_enlace\" type=\"text\" name=\"nom_enlace\" maxlength=\"50\" title=\"Nombre del enlace\"/>\n");
      out.write("\t\t\t\t\t</div>\n");
      out.write("\t\t\t\t\t<div class=\"formenlace\">\n");
      out.write("\t\t\t\t\t\t<label for=\"url_enlace\">URL</label>\n");
      out.write("\t\t\t\t\t\t<input id=\"url_enlace\" type=\"text\" name=\"url_enlace\" maxlength=\"100\" size=\"45\" title=\"Url\"/>\n");
      out.write("\t\t\t\t\t</div>\n");
      out.write("\t\t\t\t</div><!-- fin cajaformenlaces -->\n");
      out.write("\t\t\t\t<div style=\"float:left\">\n");
      out.write("\t\t\t\t\t<label for=\"tipo_enlace\">Tipo</label><br/>\n");
      out.write("\t\t\t\t\t<select id=\"tipo_enlace\" name=\"tipo_enlace\" multiple=\"multiple\" size=\"5\" title=\"Selecciona el tipo de enlace\">\n");
      out.write("\t\t\t\t\t\t");

						//consultamos los tipos de enlaces existentes en la BD
						mybean.conectar();
						List listaTipoEnlaces = mybean.getTipoEnlaces();
						Iterator it = listaTipoEnlaces.iterator();
						while(it.hasNext()){
							//El metodo Split de String separa una cadena en varias partes 
							//teniendo como delimitador la expresion regular que se pase como 
							//parametro
							String [] valorTipo = ((String) it.next()).split(",");
							
      out.write("\n");
      out.write("\t\t\t\t\t\t\t<option onclick=\"habilitar('btdestipos')\" value = \"");
      out.print(valorTipo[0]);
      out.write('"');
      out.write('>');
      out.print(valorTipo[1]);
      out.write("</option>\n");
      out.write("\t\t\t\t\t\t");

						}//fin while
						mybean.desconectar();
					
      out.write("\n");
      out.write("\t\t            </select><br/>\n");
      out.write("\t\t            <button id=\"btdestipos\" class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\" disabled=\"disabled\" onfocus=\"borrarTiposSeleccionados('tipo_enlace', this);\" title=\"Deseleccionar tipos\">Deseleccionar tipos</button>\n");
      out.write("\t\t        </div><!-- fin div float:left -->\n");
      out.write("\t\t       \t\t<div id=\"btnbuscarenlace\">\n");
      out.write("\t\t\t\t\t\t<button class=\"mybtn\" onmouseover=\"goLite(this)\" onmouseout=\"goDim(this)\" \n");
      out.write("\t\t\t\t\t\tonclick=\"procesaParametros('lista_enlaces','form_enlaces','proc_busquedaenlace_admin.jsp', 'get');\">\n");
      out.write("\t\t\t\t\t\tBuscar</button>\n");
      out.write("\t\t\t\t\t</div>\n");
      out.write("\t\t        </fieldset>\n");
      out.write("\t        </div><!-- \"wrapper_formenlaces\" -->\n");
      out.write("\t        \n");
      out.write("\t\t</form>\n");
      out.write("\t\t</div><!-- fin div_form_enlaces -->\n");
      out.write("\t<div id=\"lista_enlaces\"></div>\n");
      out.write("\t</div><!-- fin contenido -->\n");
      out.write("\t</div><!-- fin 'content_wrapper' -->\n");
      out.write("\t<div class='spacer'></div>\n");
      out.write("\t");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "pie.html", out, false);
      out.write("\n");
      out.write("\t</div>\t<!-- fin 'page_wrapper' -->\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
